#include <bits/stdc++.h>
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
typedef long long LL;
const int N = 3e6+5;
int n;
char s[N];

template <typename T> void debug(T x) { cerr<<x; }
template <typename T, typename ..._T> void debug(T x, _T...p) { cerr<<x<<' '; debug(p...); }
template <typename T> void read(T& x) {
    x=0; int f=0; char c=getchar();
    while(c < '0' || c > '9') f|=(c == '-'), c=getchar();
    while(c >= '0' && c <= '9') x=(x<<1)+(x<<3)+(c^48), c=getchar();
    x=(f ? -x : x);
}
int lne; char put[105];
template <typename T> void write(T x, char c) {
    lne=0; if(x < 0) putchar('-'), x=-x;
    do { put[++lne]=x%10, x/=10; } while (x);
    while(lne) putchar(put[lne]^48), --lne;
    putchar(c);
}

signed main() {
    File("song");
    scanf("%s", s+1);
    int pd = 1;
    n=strlen(s+1);
    for(int i = 2; i <= n; ++i)
        pd&=(s[i] != s[i-1]);
    if(pd) {
        if(s[1] == 'A')
            write((n+1)/2, '\n');
        else
            write(n/2+1, '\n');
        return 0;
    }
    return 0;
}